/***********************************************************************************************************************************
 *    Name: Bulk_Recover.sql
 *  Author: Frank Figearo — http://www.sqlnerd.me/ — frank@sqlnerd.me
 * Summary: Execute RESTORE DATABASE [name] WITH RECOVERY for all databases in the RESTORING state.
**/
DECLARE @tsql_command NVARCHAR(MAX)= N';'
SELECT @tsql_command+= N' PRINT N''' + d.name + '''; RESTORE DATABASE [' + d.name + N'] WITH RECOVERY;' FROM sys.databases d WHERE d.state_desc = N'RESTORING';
EXECUTE (@tsql_command);
GO